<?php
global $MONTHS2, $TYPE_MAVRO, $VALUTA, $USER_SETTING;
?>
<h1>Присоединение платежа к операции</h1>

 <?php
 $users = array($user['id'] => $user);
 $this->load->view('oper/_table', array('users' => $users, 'params' => array('kro' => false, 'balance' => false, 'actions' => false))); 
?>
<br>
<h2>Платежи</h2>

<form method=post action='' enctype='multipart/form-data'>
<input type='hidden' name='go' value='1'>
<table class='list' cellspacing=0 style="width:auto;">
<thead>
	<tr>
		<th></th>
		<th>Счёт</th>
		<th>Дата перевода</th>
		<th>Дата поступления</th>
		<th>От кого</th>
		<th>Кому</th>
		<th>Валюта</th>
		<th>Сумма</th>
		<th>Комиссия</th>
		<th>Итого</th>
		<th>Файлы</th>
		<th>Комментарий</th>
	</tr>
</thead>
<tbody>
<?php
	foreach($platezhi as $p) 
	{
		$class = isPlatezhBuy($p) ? 'buy' : 'sell';
		?>
		<tr>
			<td class='action'><input type='radio' name='platezh_id' value='<?=$p['id']?>'></td>
			<td><?=$p['schet_name']?></td>
			<td align=center><?=date("d.m.Y", strtotime($p['from_date']))?></td>
			<td align=center><?=date("d.m.Y", strtotime($p['to_date']))?></td>
			<td><?=@$p['user_from']?></td>
			<td><?=@$p['user_to']?></td>
			<td align=center class='<?=$class?>'><?=$VALUTA[$p['valuta']]?></td>
			<td align=right class='<?=$class?>'><?=number_format($p['summ'], 2, $USER_SETTING['znak_drob'], ' ')?></td>
			<td align=right class='<?=$class?>'><?=number_format($p['komiss'], 2, $USER_SETTING['znak_drob'], ' ')?></td>
			<td align=right class='<?=$class?>'><?=number_format($p['itogo'], 2, $USER_SETTING['znak_drob'], ' ')?></td>
			<td class='action'><?php
			for($i = 1; $i <= 5; $i++)
			{
				$filename = $p['file'.$i."_comment"] ? $p['file'.$i."_comment"] : "Файл ".$i;
				if($p['file'.$i]) {?>
				<a href='<?=UPLOAD_PATH.$p['file'.$i]?>' target=_blank><?=$filename?></a><br>
				<? }
			}
			?></td>
			<td><?=nl2br(htmlspecialchars($p['comment']))?></td>
		</tr>
		<?php
}

 ?>
</tbody>
</table>

<br><br>
<input type='submit' value='Сохранить'>
</form>